using System;
using System.IO;
namespace UraniaLib
{
	/// <summary>
	/// Summary description for UraniaGenConst.
	/// </summary>
	public class UraniaGenConst
	{
		//Presets
		public string cVersion = "1.2";

		//Options
		public long lLocalTimeZone = 0;
		public double fLocalLong = 0;
		public double fLocalLat = 0;
		public long lEpoch = 1990;
		public bool bUseEpoch;
		public int lDecPlace = 2;
		public string sCity = "";
		public string sState = "";
		public string sCountry = "";

		public UraniaGenConst()
		{
			FileStream oFile = new FileStream("Options.dat", FileMode.OpenOrCreate, FileAccess.Read);
			StreamReader oRead = new StreamReader(oFile);
			
			if (oFile.Length > 1)
			{

				fLocalLong = Convert.ToDouble(oRead.ReadLine());
				fLocalLat = Convert.ToDouble(oRead.ReadLine());
				lLocalTimeZone = Convert.ToInt16(oRead.ReadLine());
				lEpoch = Convert.ToInt16(oRead.ReadLine());
				bUseEpoch = Convert.ToBoolean(oRead.ReadLine());
				lDecPlace = Convert.ToInt16(oRead.ReadLine());
				sCity = oRead.ReadLine();
				sState = oRead.ReadLine();
				sCountry = oRead.ReadLine();
			}
			oRead.Close();
			oFile.Close();
		}

		public void WriteChanges()
		{
			FileStream oFile = new FileStream("Options.dat", FileMode.Truncate, FileAccess.Write);
			StreamWriter oWrite = new StreamWriter(oFile);

			oWrite.WriteLine(fLocalLong);
			oWrite.WriteLine(fLocalLat);
			oWrite.WriteLine(lLocalTimeZone);
			oWrite.WriteLine(lEpoch);
			oWrite.WriteLine(bUseEpoch);
			oWrite.WriteLine(lDecPlace);
			oWrite.WriteLine(sCity);
			oWrite.WriteLine(sState);
			oWrite.WriteLine(sCountry);
			oWrite.Close();
			oFile.Close();

		}
	}
}
